package ModelLayer;

import java.sql.Timestamp;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public abstract class DateHelper {
	
	protected Timestamp date;
	private Calendar cal = Calendar.getInstance();
	
	public static final SimpleDateFormat dateFormatter     = new SimpleDateFormat("dd.MM.yyyy");
	public static final SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
	public static final SimpleDateFormat timeFormatter     = new SimpleDateFormat("HH:mm");
	
	
	public DateHelper(){
		setDate();
	}
	
	public DateHelper(Timestamp date){
		setDate(date);
	}
	
	public DateHelper(Date date){
		setDate(date);
	}
	
	public DateHelper(java.util.Date date){
		setDate(date);
	}
	
	
	
	
	
	public String getDateFormated(){
		return dateFormatter.format(date);
	}
	
	public String getDateTimeFormated(){
		return dateTimeFormatter.format(date);
	}
	
	public String getTimeFormated(){
		return timeFormatter.format(date);
	}
	
	
	
	
	public int getSeconds(){
		return cal.get(Calendar.SECOND);
	}
	
	public int getMinutes(){
		return cal.get(Calendar.MINUTE);
	}
	
	public int getHour(){
		return cal.get(Calendar.HOUR_OF_DAY);
	}
	
	public int getDay(){
		return cal.get(Calendar.DAY_OF_MONTH);
	}
	
	public int getMonth(){
		return cal.get(Calendar.MONTH);
	}
	
	public int getYear(){
		return cal.get(Calendar.YEAR);
	}
	
	
	
	
	
	
	
	public Timestamp getDate() {
		return date;
	}

	public void setDate(Timestamp date) {
		this.date = date;
		setCal();
	}
	
	public void setDate(Date date) {
		this.date = new Timestamp(date.getTime());
		setCal();
	}
	
	public void setDate(java.util.Date date) {
		this.date = new Timestamp(date.getTime());
		setCal();
	}
	
	public void setDate() {
		this.date = new Timestamp((new java.util.Date()).getTime());
		setCal();
	}
	
	
	private void setCal(){
		cal.setTime(date);
	}
	
}
